package com.etone.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.etone.common.annotation.Log;
import com.etone.common.core.controller.BaseController;
import com.etone.common.core.domain.AjaxResult;
import com.etone.common.enums.BusinessType;
import com.etone.system.domain.SixFreetask;
import com.etone.system.service.ISixFreetaskService;
import com.etone.common.utils.poi.ExcelUtil;
import com.etone.common.core.page.TableDataInfo;

/**
 * 保存等待执行任务Controller
 *
 * @author etone
 * @date 2025-07-02
 */
@RestController
@RequestMapping("/system/freetask")
public class SixFreetaskController extends BaseController
{
    @Autowired
    private ISixFreetaskService sixFreetaskService;

    /**
     * 查询保存等待执行任务列表
     */
    @PreAuthorize("@ss.hasPermi('system:freetask:list')")
    @GetMapping("/list")
    public TableDataInfo list(SixFreetask sixFreetask)
    {
        startPage();
        List<SixFreetask> list = sixFreetaskService.selectSixFreetaskList(sixFreetask);
        return getDataTable(list);
    }

    /**
     * 导出保存等待执行任务列表
     */
    @PreAuthorize("@ss.hasPermi('system:freetask:export')")
    @Log(title = "保存等待执行任务", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SixFreetask sixFreetask)
    {
        List<SixFreetask> list = sixFreetaskService.selectSixFreetaskList(sixFreetask);
        ExcelUtil<SixFreetask> util = new ExcelUtil<SixFreetask>(SixFreetask.class);
        util.exportExcel(response, list, "保存等待执行任务数据");
    }

    /**
     * 获取保存等待执行任务详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:freetask:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sixFreetaskService.selectSixFreetaskById(id));
    }

    /**
     * 新增保存等待执行任务
     */
    @PreAuthorize("@ss.hasPermi('system:freetask:add')")
    @Log(title = "保存等待执行任务", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SixFreetask sixFreetask)
    {
        return toAjax(sixFreetaskService.insertSixFreetask(sixFreetask));
    }

    /**
     * 修改保存等待执行任务
     */
    @PreAuthorize("@ss.hasPermi('system:freetask:edit')")
    @Log(title = "保存等待执行任务", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SixFreetask sixFreetask)
    {
        return toAjax(sixFreetaskService.updateSixFreetask(sixFreetask));
    }

    /**
     * 删除保存等待执行任务
     */
    @PreAuthorize("@ss.hasPermi('system:freetask:remove')")
    @Log(title = "保存等待执行任务", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sixFreetaskService.deleteSixFreetaskByIds(ids));
    }
}
